
-----------------------------------------------------------------------------
-- 1.语法高亮
-- 2.git
-----------------------------------------------------------------------------
return {

    -----------------------------------------------------------------------------
    -- ## 美化diagnostics
    -- https://github.com/folke/trouble.nvim
    -- 命令 :Trouble [mode]
    -- 命令 :TroubleClose [mode]
    -- 命令 :TroubleToggle [mode]
    -- - mode 
    --  - document_diagnostics
    --  - workspace_diagnostics 
    --  - lsp_references
    --  - lsp_definitions
    --  - quickfix
    --  - locklist
    -----------------------------------------------------------------------------
     {
        "folke/trouble.nvim",
        dependencies = "nvim-tree/nvim-web-devicons",
        opts = {
            mode = "workspace_diagnostics",
            icons = true, -- use devicons for filenames
        },
    },

    -----------------------------------------------------------------------------
    -- 浮窗显示lsp
    -- https://github.com/rmagatti/goto-preview
    -- require('goto-preview').goto_preview_definition()
    -- require('goto-preview').goto_preview_type_definition()
    -- require('goto-preview').goto_preview_implementation()
    -- require('goto-preview').close_all_win()
    -- require('goto-preview').goto_preview_references()

    -----------------------------------------------------------------------------
    {
        "rmagatti/goto-preview",
        config = function()
            require('goto-preview').setup {}
        end,
        keys = require("keybinding")["goto-preview"](),
    },


    ------------------------------------------------------------------------
    -- ## todo-comments
    -- 命令 TodoTrouble
    -- 命令 TodoTelescope
    -- 命令 TodoLocList
    -- 命令 TodoQuickFix
    -- https://github.com/folke/todo-comments.nvim
    ------------------------------------------------------------------------
    {
        "folke/todo-comments.nvim",
        dependencies = "nvim-lua/plenary.nvim",
        keys = require("keybinding")["todo-comments"](),
        lazy = false,
        config = function()
            local todo = require("todo-comments")
            local options = {
                keywords = {
                    -- alt = alias
                    FIX = {
                        icon = " ",
                        color = "#DC2626",
                        alt = {"FIXME", "BUG", "FIXIT", "ISSUE", "!"}
                    },
                    TODO = {icon = " ", color = "#10B981"},
                    HACK = {icon = " ", color = "#7C3AED"},
                    WARN = {icon = " ", color = "#FBBF24", alt = {"WARNING", "XXX"}},
                    PERF = {icon = " ", color = "#FC9868", alt = {"OPTIM", "PERFORMANCE", "OPTIMIZE"}},
                    NOTE = {icon = " ", color = "#2563EB", alt = {"INFO"}}
                }
            }
            todo.setup(options)
        end,
    },

    -----------------------------------------------------------------------------
    -- ## git
    -- https://github.com/kdheepak/lazygit.nvim
    -----------------------------------------------------------------------------
    {
        'kdheepak/lazygit.nvim',
        config = function()
            local g = vim.g
            g.lazygit_floating_window_winblend = 0                          -- transparency of floating window
            g.lazygit_floating_window_scaling_factor = 0.9                  -- scaling factor for floating window
            g.lazygit_floating_window_corner_chars = {']', '╮', '╰', '╯'}   -- customize lazygit popup window corner characters
            g.lazygit_floating_window_use_plenary = 0                       -- use plenary.nvim to manage floating window if available
            g.lazygit_use_neovim_remote = 1                                 -- fallback to 0 if neovim-remote is not installed
            g.lazygit_use_custom_config_file_path = 0                       -- config file path is evaluated if this value is 1
            g.lazygit_config_file_path = ''                                 -- custom config file path
        end,
    },

    -----------------------------------------------------------------------------
    -- ## git
    -- https://github.com/lewis6991/gitsigns.nvim
    {
        "lewis6991/gitsigns.nvim",
        config = function()
            local gitsigns = require("gitsigns")
            gitsigns.setup({
                signs = {
                    add          = { text = '┃' },
                    change       = { text = '┃' },
                    delete       = { text = '_' },
                    topdelete    = { text = '‾' },
                    changedelete = { text = '~' },
                    untracked    = { text = '┆' },
                },
                signs_staged = {
                    add          = { text = '┃' },
                    change       = { text = '┃' },
                    delete       = { text = '_' },
                    topdelete    = { text = '‾' },
                    changedelete = { text = '~' },
                    untracked    = { text = '┆' },
                },
                signs_staged_enable = true,
                signcolumn = true,  -- Toggle with `:Gitsigns toggle_signs`
                numhl      = false, -- Toggle with `:Gitsigns toggle_numhl`
                linehl     = false, -- Toggle with `:Gitsigns toggle_linehl`
                word_diff  = false, -- Toggle with `:Gitsigns toggle_word_diff`
                watch_gitdir = {
                    follow_files = true
                },
                auto_attach = true,
                attach_to_untracked = false,
                current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
                current_line_blame_opts = {
                    virt_text = true,
                    virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
                    delay = 1000,
                    ignore_whitespace = false,
                    virt_text_priority = 100,
                    use_focus = true,
                },
                current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
                sign_priority = 6,
                update_debounce = 100,
                status_formatter = nil, -- Use default
                max_file_length = 40000, -- Disable if file is longer than this (in lines)
                preview_config = {
                    -- Options passed to nvim_open_win
                    border = 'single',
                    style = 'minimal',
                    relative = 'cursor',
                    row = 0,
                    col = 1
                },
                on_attach = require("keybinding").gitsigns_on_attach,
            })
        end,
    },

    -----------------------------------------------------------------------------
    -- ## 方法高亮
    -- https://github.com/m-demare/hlargs.nvim
    -----------------------------------------------------------------------------
    {
        "m-demare/hlargs.nvim",
        dependencies = "nvim-treesitter/nvim-treesitter",
        enabled = false,
        config = function()
            local hlargs = require("hlargs")
            hlargs.setup {
                color = "#ef9062",
                excluded_filetypes = {},
                paint_arg_declarations = true,
                paint_arg_usages = true,
                hl_priority = 10000,
                excluded_argnames = {
                    declarations = {},
                    usages = {
                        python = { 'self', 'cls' },
                        lua = { 'self' }
                    }
                },
                performance = {
                    parse_delay = 1,
                    slow_parse_delay = 50,
                    max_iterations = 400,
                    max_concurrent_partial_parses = 30,
                    debounce = {
                        partial_parse = 3,
                        partial_insert_mode = 100,
                        total_parse = 700,
                        slow_parse = 5000
                    }
                }
            }
        end,
    },


    -----------------------------------------------------------------------------
    -- ## 当前方法吸顶
    -- https://github.com/nvim-treesitter/nvim-treesitter-context
    -----------------------------------------------------------------------------
    {
        "nvim-treesitter/nvim-treesitter-context",
        dependencies = "nvim-treesitter/nvim-treesitter",
        config = function()
            local context = require("treesitter-context")
            context.setup {
                enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
                max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
                patterns = {
                    -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
                    -- For all filetypes
                    -- Note that setting an entry here replaces all other patterns for this entry.
                    -- By setting the 'default' entry below, you can control which nodes you want to
                    -- appear in the context window.
                    default = {
                        "class",
                        "function",
                        "method",
                        "func",
                        "for", -- These won't appear in the context
                        "while",
                        "if",
                        "switch",
                        "case",
                        "interface",
                        "struct",
                        "enum",
                    }
                    -- Example for a specific filetype.
                    -- If a pattern is missing, *open a PR* so everyone can benefit.
                    --   rust = {
                    --       'impl_item',
                    --   },
                },
                exact_patterns = {},
                -- [!] The options below are exposed but shouldn't require your attention,
                --     you can safely ignore them.

                zindex = 20 -- The Z-index of the context window
            }
        end
    },

    -----------------------------------------------------------------------------
    -- ## 显示相同的单词
    -- https://github.com/RRethy/vim-illuminate
    -----------------------------------------------------------------------------
    {
        "RRethy/vim-illuminate",
        dependencies = "nvim-treesitter/nvim-treesitter",
        config = function()
            -- 禁止高亮的文件类型
            -- 虽然 toggleterm 还没有安装
            -- 但并不影响使用，反正后续都会装上
            vim.g.Illuminate_ftblacklist = {
                "NvimTree",
                "neo-tree",
                "toggleterm"
            }
        end,
    },

    -- ## 语法高亮
    ------------------------------------------------------------------------
    --  < nvim-treesitter 插件配置 > 
    --  1.语法高亮
    --  2.增量选择
    --  3.代码格式化
    --  4.代码折叠
    --  https://github.com/nvim-treesitter/nvim-treesitter
    -----------------------------------------------------------------------------
    -- https://github.com/nvim-treesitter/nvim-treesitter
    {
        'nvim-treesitter/nvim-treesitter',
        config = function()
            local opts = {
                -- 安装 language parser
                -- :TSInstallInfo 命令查看支持的语言
                ensure_installed = {
                    -- "help",
                     "bash",
                     "python",
                     "c",
                     "lua",
                    "markdown",
                    "markdown_inline",
                    -- "go",
                    -- "php",
                    -- "css",
                    -- "javascript", 
                    -- "typescript", 
                    -- "tsx",
                },
                auto_install = true,
                sync_install = true,
                -- 启用代码高亮功能
                highlight = {
                    enable = true,
                    additional_vim_regex_highlighting = false
                },
                -- 启用增量选择
                incremental_selection = {
                    enable = true,
                    keymaps = {
                        init_selection = '<CR>',
                        node_incremental = '<CR>',
                        node_decremental = '<BS>',
                        scope_incremental = '<TAB>',
                    }
                },
                -- 启用基于Treesitter的代码格式化(=) . NOTE: This is an experimental feature.
                indent = {
                    enable = true
                },
                rainbow = {
                    enable = true,
                    extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
                    max_file_lines = nil, -- Do not enable for files with more than n lines, int
                    -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
                    -- colors = {}, -- table of hex strings
                    -- termcolors = {} -- table of colour name strings
                }
            }
            require 'nvim-treesitter.configs'.setup(opts)
            -- 开启 Folding
            vim.wo.foldmethod = 'expr'
            vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'
            vim.wo.foldenable = false
        end,
    },

    -----------------------------------------------------------------------------
    -- ## 彩虹括号
    -- https://github.com/p00f/nvim-ts-rainbow
    {
        "p00f/nvim-ts-rainbow",
        dependencies = {"nvim-treesitter/nvim-treesitter"},
    },


    -----------------------------------------------------------------------------
    -- ## 对齐线
    -- https://github.com/lukas-reineke/indent-blankline.nvim
    -----------------------------------------------------------------------------

    -----------------------------------------------------------------------------
    -- ## 注释
    -- https://github.com/numToStr/Comment.nvim
    -----------------------------------------------------------------------------
    {
        "numToStr/Comment.nvim",
        config = function()
            local comment = require("Comment")

            -- https://github.com/numToStr/Comment.nvim
            local default_opts = {
                ---Add a space b/w comment and the line
                ---@type boolean|fun():boolean
                padding = true,
                ---Whether the cursor should stay at its position
                ---NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat
                ---@type boolean
                sticky = true,
                ---Lines to be ignored while comment/uncomment.
                ---Could be a regex string or a function that returns a regex string.
                ---Example: Use '^$' to ignore empty lines
                ---@type string|fun():string
                ignore = nil,
                ---LHS of toggle mappings in NORMAL + VISUAL mode
                ---@type table
                toggler = {
                    ---Line-comment toggle keymap
                    line = "gcc",
                    ---Block-comment toggle keymap
                    block = "gbc"
                },
                ---LHS of operator-pending mappings in NORMAL + VISUAL mode
                ---@type table
                opleader = {
                    ---Line-comment keymap
                    line = "gc",
                    ---Block-comment keymap
                    block = "gb"
                },
                ---LHS of extra mappings
                ---@type table
                extra = {
                    ---Add comment on the line above
                    above = "gcO",
                    ---Add comment on the line below
                    below = "gco",
                    ---Add comment at the end of line
                    eol = "gcA"
                },
                ---Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode
                ---NOTE: If `mappings = false` then the plugin won't create any mappings
                ---@type boolean|table
                mappings = {
                    ---Operator-pending mapping
                    ---Includes `gcc`, `gbc`, `gc[count]{motion}` and `gb[count]{motion}`
                    ---NOTE: These mappings can be changed individually by `opleader` and `toggler` config
                    basic = true,
                    ---Extra mapping
                    ---Includes `gco`, `gcO`, `gcA`
                    extra = true,
                    ---Extended mapping
                    ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
                    extended = false
                },
                ---Pre-hook, called before commenting the line
                ---@type fun(ctx: Ctx):string
                ---@param ctx Ctx
                pre_hook = function(ctx)
                    -- Only calculate commentstring for tsx filetypes
                    if vim.bo.filetype == "typescriptreact" then
                        local U = require("Comment.utils")

                        -- Determine whether to use linewise or blockwise commentstring
                        local type = ctx.ctype == U.ctype.line and "__default" or "__multiline"

                        -- Determine the location where to calculate commentstring from
                        local location = nil
                        if ctx.ctype == U.ctype.block then
                            location = require("ts_context_commentstring.utils").get_cursor_location()
                        elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
                            location = require("ts_context_commentstring.utils").get_visual_start_location()
                        end

                        return require("ts_context_commentstring.internal").calculate_commentstring(
                        {
                            key = type,
                            location = location
                        }
                        )
                    end
                end,
                ---Post-hook, called after commenting is done
                ---@type fun(ctx: Ctx)
                post_hook = nil
            }
            -- 关闭了extra快捷键，只用keybinding里定义的基础快捷键
            comment.setup(vim.tbl_deep_extend("force", default_opts, require("keybinding").comment))
            comment.setup(default_opts)
        end,
    },

    -----------------------------------------------------------------------------
    -- ## 格式化
    -- https://github.com/sbdchd/neoformat
    -- WARN: neoformat install the formatter manually
    -- https://github.com/sbdchd/neoformat#supported-filetypes

    -- npm install -g lua-fmt
    -- npm install -g prettier
    -- npm install -g prettier-eslint-cli
    -- npm install -g gofmt
    -- pip3 install autopep8
    -- pip3 install sqlformat
    -----------------------------------------------------------------------------
    {
        enabled = false,
        "sbdchd/neoformat",
        config = function()
            local g = vim.g
            -- 1. auto align
            g.neoformat_basic_format_align = 1
            -- 2. automatically remove trailing whitespace
            g.neoformat_basic_format_trim = 1
            -- 3. replace tabs with spaces
            g.neoformat_basic_format_retab = 0

            -- only show error messages
            g.neoformat_only_msg_on_error = 1
        end,
    },

    ---------------------------------------
    -- 不知道是什么 
    ---------------------------------------

    -- ## 执行代码片段
    -- https://github.com/michaelb/sniprun
    -- {"michaelb/sniprun"},


    -- ## 截图
    -- {"kristijanhusak/vim-carbon-now-sh", cmd = "CarbonNowSh"},

 
}
